<!--
 * @Author: wxj
 * @Description: 
-->
<template>
  <div class="home">home</div>
  <h2>
    <i class="el-icon-platform-eleme"></i>
    h2
  </h2>
  <el-button>hello</el-button>
  <el-button @click="Message">message</el-button>
  <router-link to="/about">about</router-link>
  <h1>
    data---{{ data }}
    <HelloWorld v-model="data" />
  </h1>

  <hr />
  <h1>
    {{ userdata && userdata.address }}
  </h1>
</template>

<script>
import { onMounted, reactive, toRefs } from "vue";
import { ElMessage } from "element-plus";
import { getStructure } from "@/api";
import HelloWorld from "@/components/HelloWorld.vue";
import axios from "axios";
export default {
  name: "Home",
  components: {
    HelloWorld,
  },
  setup(props) {
    const state = reactive({
      userdata: null,
      data: "wxj",
    });

    onMounted(() => {
      axios.get("/api/user/login").then((res) => {
        console.log(res.data.data);
        state.userdata = res.data.data;
      });
    });

    async function Message() {
      ElMessage.success({
        message: "恭喜你，发送了一个ajax",
        type: "success",
      });
      let data = await getStructure();
      console.log(data.data);
    }
    return {
      ...toRefs(state),
      Message,
    };
  },
};
</script>

<style lang="scss" scoped>
h2 {
  color: $Color;
  font-size: $Font_60;
}
</style>
